//
//  TableviewGroupStyleVC.m
//  UILbrary
//
//  Created by mac on 17/1/11.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "TableviewGroupStyleVC.h"

@interface TableviewGroupStyleVC ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableview;
@property (nonatomic, strong) NSArray *cellTitleArr;
@end

@implementation TableviewGroupStyleVC

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"Tableview GroupStyle";
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.tableview];
}


#pragma mark - tableview delegate 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.cellTitleArr[section] count];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.cellTitleArr.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 44.0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    cell.textLabel.text = self.cellTitleArr[indexPath.section][indexPath.row];
    return cell;
}

#pragma mark - lazy methods
- (UITableView *)tableview{
    if (!_tableview) {
        _tableview = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableview.tableFooterView = [UIView new];
        _tableview.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        [_tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
        _tableview.delegate = self;
        _tableview.dataSource = self;
    }
    return _tableview;
}

- (NSArray *)cellTitleArr{
    return @[@[@"个人信息",@"收货地址"],
             @[@"退出登录"]];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
